package com.deer.im.util;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.deer.im.service.IMessageService;

/**
 * @功能描述 监听器中注入
 * @创建时间 2020/10/21 15:48
 **/
@Component
public class InjectServiceUtil {

    @Autowired
    private IMessageService messageService;

    @PostConstruct
    public void init(){
        InjectServiceUtil.getInstance().messageService = this.messageService;
    }

    /**
     *  实现单例 start
     */
    private static class SingletonHolder {
        private static final InjectServiceUtil INSTANCE = new InjectServiceUtil();
    }
    
    private InjectServiceUtil (){}
    
    public static final InjectServiceUtil getInstance() {
        return SingletonHolder.INSTANCE;
    }
    
    /**
     *  实现单例 end
     */
    public IMessageService sendMessage(){
        return InjectServiceUtil.getInstance().messageService;
    }
}




